package com.dog.basics.api.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.api.mtkj.ApiBankAccountAddDto;
import com.dog.basics.bean.dto.api.mtkj.ApiBankAccountEditDto;
import com.dog.basics.bean.vo.api.mtkj.ApiBankAccountVo;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.mtkj.IMtBankAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 绑定银行账户 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-11-09
 */
@RestController
@Api(value = "商户绑定银行账户", tags = SwaggerConstants.API_ALL)
@RequestMapping("api/bank/account")
@AllArgsConstructor
public class MtBankAccountController {
    private final IMtBankAccountService mtBankAccountService;

    /**
     * @Description: 获取银行卡列表
     * @Param: page
     * @return: IPage<BankAccountVo>
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @GetMapping
    @ApiOperation(value = "获取银行卡列表", notes = "获取银行卡列表", tags = SwaggerConstants.API_SHOPPINGMONEY)
    public R<IPage<ApiBankAccountVo>> getPageList(PageParam page) {
        return R.ok(mtBankAccountService.getPageList(page));
    }


    /**
     * @Description: 新增银行卡
     * @Param: BankAccountAddDto
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @PostMapping
    @ApiOperation(value = "新增银行卡", notes = "新增银行卡", tags = SwaggerConstants.API_SHOPPINGMONEY)
    public R<Boolean> saveObj(@Valid @RequestBody ApiBankAccountAddDto obj) {
        return R.ok(mtBankAccountService.saveObj(obj));
    }

    /**
     * @Description: 修改银行卡
     * @Param: page
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */

    @PutMapping
    @ApiOperation(value = "修改银行卡", notes = "修改银行卡", tags = SwaggerConstants.API_SHOPPINGMONEY)
    public R<Boolean> editObj(@Valid @RequestBody ApiBankAccountEditDto obj) {
        return R.ok(mtBankAccountService.editObj(obj));
    }


    /**
     * @Description: 删除银行卡
     * @Param: id
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @DeleteMapping
    @ApiOperation(value = "删除银行卡", notes = "删除银行卡", tags = SwaggerConstants.API_SHOPPINGMONEY)
    @ApiImplicitParam(name = "ids", value = "标识Ids", dataType = "List<Long>", required = true)
    public R<Boolean> delAddress(@RequestBody List<Long> ids) {
        return R.ok(mtBankAccountService.deleteObj(ids));
    }

    /**
     * @Description: 小程序订阅消息测试
     * @Param: page
     * @return: Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @Inner
    @GetMapping("/cs")
    @ApiOperation(value = "小程序订阅消息测试", notes = "小程序订阅消息测试", tags = SwaggerConstants.API_SHOPPINGMONEY)
    public R<Boolean> cs(String openId, String keyword1, String keyword2) {
        return R.ok(mtBankAccountService.cs(openId, keyword1, keyword2));
    }
}
